package ru.integrationmessagers.vk.model.dto.mapper.self;

import ru.integrationmessagers.vk.model.domain.AbstractModel;
import ru.integrationmessagers.vk.model.dto.self.AbstractDto;

import java.util.List;
import java.util.stream.Collectors;

public abstract class AbstractMapper<DTO extends AbstractDto, M extends AbstractModel>
        implements EntitiesMapper<DTO, M> {

    protected void setBaseDtoFields(DTO dto, M model) {
        dto.setId(model.getId());
    }

    @Override
    public List<DTO> toListDto(List<M> models) {
        return models.stream()
                .map(this::toDto)
                .collect(Collectors.toList());
    }
}
